package com.itheima.d6_object_stream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;

/*
  目标：掌握对象字节输出流的使用：序列化对象。
 */
public class Test1ObjectOutputStream {
    public static void main(String[] args) throws Exception {
        FileOutputStream fos = new FileOutputStream("object.txt");
        ObjectOutputStream oos = new ObjectOutputStream(fos);

        Student s1 = new Student("张三丰", 1888, 88.8);
        Student s2 = new Student("亚瑟王", 1888, 88.8);
        Student s3 = new Student("朱元璋", 88, 88.8);
        Student s4 = new Student("张居正", 88, 88.8);
        Student s5 = new Student("朱棣", 55, 88.8);
        ArrayList<Student> students = new ArrayList<>();
        Collections.addAll(students,s1,s2,s3,s4,s5);

        oos.writeObject(students);
        oos.close();

    }

}
